dofile("adds.lua")

ContextMenu = {}
_CM = {}

cmx, cmy = 0, 0

function ContextMenu.init (cm, x, y, choix)
  _CM[cm] = {}
  
  _CM[cm].x = x
  _CM[cm].y = y
  
  _CM[cm].choix = choix
end

function ContextMenu.draw (cm)
  if Stylus.held then
    cmx = Stylus.X
    cmy = Stylus.Y
  end
  
  for i=1, table.getn (_CM[cm].choix) do
    screen.print (SCREEN_DOWN, _CM[cm].x, _CM[cm].y, _CM[cm].choix[i])
    screen.drawFillRect (SCREEN_DOWN, _CM[cm].x, _CM[cm].y, _CM[cm].x+45, _CM[cm].y+(table.getn (_CM[cm].choix)*8), c_blanc)
    screen.drawRect (SCREEN_DOWN, _CM[cm].x, _CM[cm].y, _CM[cm].x+45, _CM[cm].y+(table.getn (_CM[cm].choix)*8), c_noir)
  end
end

function ContextMenu.clear (cm)
  _CM[cm] = nil
  
  cmx, cmy = nil
end

